<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 飞蓬
  Date: 2018/4/25
  Time: 16:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">
    <jsp:include page="../js_top.jsp"></jsp:include>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
    <style type="text/css">
        .table_report{width:540px;margin:15px auto;}
        .table_report tr td{line-height:31px;color:#63666d;font-size:14px;font-family:Arial,Helvetica,"微软雅黑";}
        .table_report tr td a{width:185px;height:38px;line-height:38px;-webkit-border-radius:5px;border-radius:5px;border-color:#b7bacb;display:block;font-size:14px;font-family:"微软雅黑";text-shadow:0 0px 0 rgba(0,0,0,0)!important;background:#b7bacb url(/static/img/images/table_report_icon1.png) no-repeat 70px center;text-align:center;color:#fff;cursor:pointer;text-indent:20px;float:left;margin:0 20px 0 0;}

        .table_report tr td a:hover,.table_report tr:last-child td:last-child a:hover{background-color:#0fb1d6;text-decoration:none;}
        input:focus:invalid:focus, textarea:focus:invalid:focus, select:focus:invalid:focus{border-color:#f59942;}
    </style>


</head>

<body>
<form action="" id="saveForm" name="saveForm" method="post">
    <input type="hidden" name="id" id="id" value="${timelineupdate.id}" />
    <input type="hidden" name="doctorId" id="doctorId" value="${timeline.doctorId}" />
    <table class="table  table-striped table-hover table_report">
        <tr>
            <td >日期</td>
            <td><input type="text"  id="date" name = "date" value="${timelineupdate.date}" class="Wdate" onFocus="javascript:WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd',minDate:'%y-%M-%d'})" style="font-size: 14px; font-family: 微软雅黑, 宋体, 黑体;width: 180px;height:30px;margin-bottom:0px;" /></td>
        </tr>
        <tr>
            <td>开始时间</td>
            <td><input type="text"  id="starttime" name = "starttime" value="${timelineupdate.starttime}" class="Wdate" onFocus="javascript:WdatePicker({skin:'whyGreen',dateFmt:'HH:mm:ss'})" style="font-size: 14px; font-family: 微软雅黑, 宋体, 黑体;width: 180px;height:30px;margin-bottom:0px;" /></td>
        </tr>
        <tr>
            <td>结束时间</td>
            <td><input type="text"  id="endtime" name = "endtime" value="${timelineupdate.endtime}" class="Wdate" onFocus="javascript:WdatePicker({skin:'whyGreen',dateFmt:'HH:mm:ss'})" style="font-size: 14px; font-family: 微软雅黑, 宋体, 黑体;width: 180px;height:30px;margin-bottom:0px;" /></td>
        </tr>
        <tr>
            <td>可预约人数</td>
            <td><input type="text" name="quato" id="quato" value="${timelineupdate.quato}"/></td>
        </tr>
        <tr>
            <td>是否有效</td>
            <td>
                <select id="status" name="status" class="form-control" style="width: 180px">
                    <c:if test="${timelineupdate.status == '0'}">
                        <option value="0" selected>无效</option>
                        <option value="1">有效</option>
                    </c:if>
                    <c:if test="${timelineupdate.status != '0'}">
                        <option value="0">无效</option>
                        <option value="1" selected>有效</option>
                    </c:if>
                </select>
            </td>
        </tr>
        <tr>
            <td colspan="10">
                <a  style="margin-left: 66px"  href="javascript:save();">确定</a>
                <a href="javascript:top.Dialog.close();">取消</a>
            </td>
        </tr>
    </table>
</form>
</body>
<script type="text/javascript">
    $(function($){
//  	var userId=$('#userId').val();
//  	if(userId !=null && userId != ""){
//  		$('#loginName').attr({readonly:"true"});
//  	};

    });
    function save(){
        var date = $('#date').val().trim();
        if(date === null || date === ''){
            $('#date').tips({
                side:3,
                msg:'日期不能为空！',
                bg:'#AE81FF',
                time:3
            });
            $('#date').focus();
            return false;
        }
        var starttime = $('#starttime').val().trim();
        if(starttime === null || starttime === ''){
            $('#starttime').tips({
                side:3,
                msg:'开始时间不能为空！',
                bg:'#AE81FF',
                time:3
            });
            $('#starttime').focus();
            return false;
        }
        var endtime = $('#endtime').val().trim();
        if(endtime === null || endtime === ''){
            $('#endtime').tips({
                side:3,
                msg:'结束时间不能为空！',
                bg:'#AE81FF',
                time:3
            });
            $('#endtime').focus();
            return false;
        }
        var quato = $('#quato').val().trim();
        if(quato === null || quato === ''){
            $('#quato').tips({
                side:3,
                msg:'可预约人数不能为空！',
                bg:'#AE81FF',
                time:3
            });
            $('#quato').focus();
            return false;
        }
        var id = '${timelineupdate.id}';
        if(id == '' || id == null || id == undefined){
            $.ajax({
                cache: true,
                type: "POST",
                url:'<%=basePath%>hs/timeline/save.do',
                data:$('#saveForm').serialize(),
                async: false,
                error: function(request) {
                    layer.msg('<span style="color:white;">插入数据出错 !</span>');
                },
                success: function(data) {
                    if(data=true){
                        top.Dialog.close();
                    }else{
                        layer.msg('<span style="color:white;">插入数据出错 !</span>');
                    }
                }
            });
        }else{
            $.ajax({
                cache: true,
                type: "POST",
                url:'<%=basePath%>hs/timeline/save.do',
                data:$('#saveForm').serialize(),
                async: false,
                error: function(request) {
                    layer.msg('<span style="color:white;">更新数据出错 !</span>');
                },
                success: function(data) {
                    if(data=true){
                        top.Dialog.close();
                    }
                }
            });
        }


    }
</script>
</html>
